<?php

namespace app\api\controller;

use think\Db;
use app\common\controller\Api;

/****
 * Class    Index
 * @name    首页API文件
 * @author  晓月老板<1434926265@qq.com>
 * @date    2020/05/20 09:38 AM
 * @package app\api\controller
 */
class Index extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /***
     * @name    首页API接口
     * @author  晓月老板<1434926265@qq.com>
     * @date    2020/05/20 09:38 AM
     * @return  string<json>
     */
    public function index()
    {
        $this->success('请求成功', []);
    }


    /***
     * @name    获取学校列表
     * @author  晓月老板<1434926265@qq.com>
     * @date    2020/05/20 09:38 AM
     * @return  string<json>
     */
    public function get_school_list()
    {

        $data = Db::name("school")->where(array("status"=>1))->select();

        $this->success('请求成功', $data);

    }


    /***
     * @name    获取银行列表
     * @author  晓月老板<1434926265@qq.com>
     * @date    2020/05/20 09:38 AM
     * @return  string<json>
     */
    public function get_bank_list()
    {

        $data = Db::name("bank")->where(array("status"=>'normal'))->order('weigh desc')->select();

        $this->success('请求成功', $data);

    }


    /***
     * @name    首页搜索接口
     * @author  晓月老板<1434926265@qq.com>
     * @date    2020/05/20 10:25 AM
     * @return  string<json>
     */
    public function search_keywords()
    {

        // 获取关键字
        $keywords = $this->request->request("keywords","","trim");

        // 查询商品数据
        $data = Db::name('shopro_goods')->where('title', 'like', '%'.$keywords.'%')->select();

        $this->success('请求成功', $data);

    }


    /***
     * @name    服务器时间
     * @author  晓月老板<1434926265@qq.com>
     * @date    2020/06/22 14:16 PM
     * @return  string<json>
     */
    public function getTime()
    {

        $this->success('请求服务器时间成功', array('time'=>time()));

    }

}
